package com.jzo2o.foundations.controller.operation;

import com.jzo2o.common.model.PageResult;
import com.jzo2o.foundations.model.domain.ServeItem;
import com.jzo2o.foundations.model.dto.request.ServePageQueryReqDTO;
import com.jzo2o.foundations.model.dto.request.ServeUpsertReqDTO;
import com.jzo2o.foundations.model.dto.response.ServeResDTO;
import com.jzo2o.foundations.service.IRegionService;
import com.jzo2o.foundations.service.IServeItemService;
import com.jzo2o.foundations.service.IServeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

/**
 * 服务表 前端控制器
 *
 * @author SumJanejzo2o-foundations
 * @since 2025-08-28
 */
@RestController("operationServeController")
@RequestMapping("/operation/serve")
@Api(tags = "服务表管理")
public class ServeController {
    @Resource
    private IServeItemService serveItemService;
    @Resource
    private IServeService serveService;


    @RequestMapping("/page")
    @ApiOperation("分页查询服务列表")
    public PageResult<ServeResDTO> myPage(ServePageQueryReqDTO servePageQueryReqDTO) {
        return serveService.myPage(servePageQueryReqDTO);
    }

    @ApiOperation("新增区域服务")
    @PostMapping("/batch")
    public void add(@RequestBody List<ServeUpsertReqDTO> serveUpsertReqDTO) {
        serveService.batchAdd(serveUpsertReqDTO);
    }

    @ApiOperation("修改服务价格")
    @PutMapping("/{id}")
    public void update(@PathVariable Long id, @RequestParam("price") BigDecimal price) {
        serveService.myUpdateServe(id, price);
    }

    @ApiOperation("上架服务")
    @PutMapping("/onSale/{id}")
    public void onSale(@PathVariable Long id) {
        serveService.onSale(id);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除服务表")
    public void delete(@Parameter(description = "服务表ID", example = "1") @PathVariable Long id) {
        serveService.myRemoveById(id);
    }
    @ApiOperation("服务下架")
    @PutMapping("/offSale/{id}")
    public void offSale(@PathVariable Long id) {
        serveService.offSale(id);
    }
    @ApiOperation("更新服务为热门")
    @PutMapping("/onHot/{id}")
    public void onHot(@PathVariable Long id) {
        serveService.onHot(id);
    }
    @ApiOperation("更新服务为非热门")
    @PutMapping("/offHot/{id}")
    public void offHot(@PathVariable Long id) {
        serveService.offHot(id);
    }

}
